﻿@using MVCMongo.Services
@model IEnumerable<DataMongo.Entities.Source>

@{
    ViewBag.Title = "Sources";
    int leftcolumnCount = 0;
    int rightcolumnCount = 0;
}

<div class="content">

    <!-- BEGIN .wrapper -->
    <div class="wrapper">

        <div class="main-content">
            <!-- BEGIN .main-page -->
            <div class="main-page">
                <!-- BEGIN .double-block -->
                <div class="double-block">

                    <!-- BEGIN .content-block -->
                    <div class="content-block main right" style="width:100%">

                        <div class="block">
                            <div class="block-title">
                                <a href="category.html" class="right"></a>
                                <h2>Sources</h2>
                            </div>
                            <div class="block-content">

                                <div class="paragraph-row">
                                    @{
                                        int remainder = (Model.Count() % 2);
                                        if (remainder > 0)
                                        {
                                            leftcolumnCount = Convert.ToInt32(Model.Count() / 2) + 1;
                                        }
                                        else
                                        {
                                            leftcolumnCount = Convert.ToInt32(Model.Count() / 2);
                                        }
                                    }
                                    <!-- BEGIN .column6 -->
                                    <div class="column6">
                                        <ul class="article-block">
                                            @foreach (var item in Model.OrderByDescending(x => x.SourceId).Take(leftcolumnCount))
                                            {
                                                <li>
                                                    <div class="article-content">
                                                        <h4><a href="@Url.RouteUrl("SourceDetails", new { id = item.SourceId, source =UtilityService.RemoveSpecialCharacters(item.ShortDescription)})" target="_blank">@item.ShortDescription ( @UtilityService.GetSourceFeedCount(item.SourceId) ) </a></h4>
                                                    </div>
                                                </li>
                                            }
                                        </ul>
                                        <!-- END .column6 -->
                                    </div>

                                    <!-- BEGIN .column6 -->
                                    @{
                                        rightcolumnCount = Model.Count() - leftcolumnCount;
                                    }
                                    <div class="column6">
                                        <ul class="article-block">
                                            @foreach (var item in Model.OrderBy(x => x.SourceId).Take(rightcolumnCount))
                                            {
                                                <li>
                                                    <div class="article-content">
                                                        <h4><a href="@Url.RouteUrl("SourceDetails", new { id = item.SourceId, source = UtilityService.RemoveSpecialCharacters(item.ShortDescription) })" target="_blank">@item.ShortDescription (@UtilityService.GetSourceFeedCount(item.SourceId)) </a></h4>
                                                    </div>
                                                </li>
                                            }

                                        </ul>
                                        <!-- END .column6 -->
                                    </div>
                                </div>
                            </div>
                        </div>



                        <!-- END .content-block -->
                    </div>

                    <!-- BEGIN .content-block -->
                    <div class="content-block left">

                    </div>
                    <!-- END .double-block -->
                </div>
                <!-- END .main-page -->
            </div>

            <!-- BEGIN .main-sidebar -->
            <div class="main-sidebar right">




            </div>
            <div class="clear-float"></div>
        </div>
        <!-- END .wrapper -->
    </div>

    <!-- BEGIN .content -->
</div>
